﻿{include file="public/header" /}

<body>
<div class="x-body">
  <fieldset class="layui-elem-field layui-field-title" style="margin-top: 5px;">
    <legend>库房类型</legend>
  </fieldset>
  <xblock>
    <a class="layui-btn"  target="_blank" href="{:url()}"><i class="iconfont">&#xe718;</i> 框架页面</a>

    <button class="layui-btn" onclick="x_admin_show('添加库房类型','{:url(\'index/StoreroomType/costAdd\')}',500,500)"><i class="layui-icon"></i>添加</button>

  </xblock>
  <div class="layui-row">
    <div class="container-wrap">
      <div class="box-1">
        <table class="layui-table">
          <thead>
          <tr>
            <th>类型名称</th>
            <th>类型描述</th>
            <th>操作</th>
          </tr>
          </thead>
          <tbody>
          {volist name="$costInfo" id = "info"}
          <tr>
            <td><?php echo "├".str_repeat("─",$info['level']*3)?>{$info.cost_name}</td>
            <td>{$info.cost_content}</td>
            <td class="td-manage" width="50px;">
              <a title="编辑" onclick="x_admin_show('修改操作','{:url(\'index/StoreroomType/costEdit\',[\'id\'=>$info.id])}',500,400)" href="javascript:;">
                <i style="color: green" class="layui-icon"></i>
              </a>
              <a title="删除" onclick="_delete(this,'{$info.id}')" href="javascript:;">
                <i  style="color:red;" class="layui-icon"></i>
              </a>
            </td>
          </tr>
          {/volist}
          </tbody>
        </table>
      </div>
    </div>
  </div>
</div>
<script>

    /*删除*/
    function _delete(obj,id){
        layer.confirm('确认要删除吗？',function(index){
            var url = "{:url('/index/storeroom_type/delete')}";
            var postData ={"id":id};
            $.post(url,postData,function (result) {
                if(result === 1 ){
                    layer.alert("删除成功", {icon: 6},function () {
                        window.location.reload();  //刷新父级页面
                    });
                }else {
                    layer.alert("删除失败", {icon: 5});
                }
            },"json");
        });
    }
</script>
</body>
</html>